package com.ruibang.glass.produce.controller.system;

import com.ruibang.glass.produce.entity.MonitorType;
import com.ruibang.glass.produce.service.MonitorTypeService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "设备监测类型接口")
@RestController
@RequestMapping("/api/glass/produce/monitorType")
public class MonitorTypeController {

    @Autowired
    private MonitorTypeService monitorTypeService;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID获取详情", response = ResultBody.class)
    public ResultBody<MonitorType> get(@PathVariable String id) {
        return ResultBody.success(monitorTypeService.getById(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增实体", response = ResultBody.class)
    public ResultBody add(@RequestBody @ApiParam("实体信息") MonitorType entity) {
        monitorTypeService.save(entity);
        return ResultBody.success(entity);
    }

    @PostMapping("/batchAdd")
    @ApiOperation(value = "批量新增实体", response = ResultBody.class)
    public ResultBody batchAdd(@RequestBody @ApiParam("实体信息") List<MonitorType> entityList) {
        monitorTypeService.saveBatch(entityList);
        return ResultBody.success();
    }

    @PutMapping("/")
    @ApiOperation(value = "修改实体", response = ResultBody.class)
    public ResultBody update(@RequestBody MonitorType entity) {
        monitorTypeService.updateById(entity);
        return ResultBody.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除实体", response = ResultBody.class)
    public ResultBody delete(@PathVariable @ApiParam("主键ID") String id) {
        monitorTypeService.removeById(id);
        return ResultBody.success();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "批量删除实体", response = ResultBody.class)
    public ResultBody delete(@RequestBody @ApiParam("主键ID") List<Object> ids) {
        monitorTypeService.removeByIds(ids);
        return ResultBody.success();
    }

    @GetMapping("/selectAll")
    @ApiOperation(value = "获取所有检测类型", response = ResultBody.class)
    public ResultBody selectAll() {
        return ResultBody.success(monitorTypeService.list());
    }


}
